package cn.topkinson.web.a.controller;

import cn.topkinson.web.a.component.WebConsumer;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 黄子濠
 * @date 2020/8/30 22:29
 */
@RestController
@RequestMapping("/")
public class HelloController {

    @Autowired
    private WebConsumer webConsumer;

    @GetMapping("/hello")
    public String hello(HttpServletRequest request){
        RpcContext.getContext().setAttachment("remoteAddr",request.getRemoteAddr());
        return webConsumer.sayHello("123", 0);
    }

    @GetMapping("/startToCall")
    public void hello(Integer times){
        webConsumer.startToCall(times);
    }
}
